// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asCameraComponent.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the CameraComponent class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asCameraComponent.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../../ScriptHelper.h"
#include "asSceneComponent.h"

#include "../../../components/scene/CameraComponent.h"


//! Reference factory for the CameraComponent class.
CameraComponent* createCameraComponent(Entity *parent)
{
    return new CameraComponent(parent);
}

//! Reference factory for the CameraComponent class.
CameraComponent* createCameraComponent(Entity *parent, const vector3df &lookat)
{
    return new CameraComponent(parent, lookat);
}

//! Binds the CameraComponent class to AngelScript.
void bindCameraComponent(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind CameraComponent class.
    r = engine->RegisterObjectType("CameraComponent", sizeof(CameraComponent), asOBJ_REF); assert(r >= 0);

    // Bind inherited functions.
    bindSceneComponentBase<CameraComponent>(engine, "CameraComponent");

    // Set CameraComponent behaviour.
    r = engine->RegisterObjectBehaviour("CameraComponent", asBEHAVE_FACTORY, "CameraComponent@ f(Entity @+)",
                                        asFUNCTIONPR(createCameraComponent, (Entity*), CameraComponent*),
                                        asCALL_CDECL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("CameraComponent", asBEHAVE_FACTORY, "CameraComponent@ f(Entity @+, " \
                                        "const vector3df &in)", asFUNCTIONPR(createCameraComponent,
                                        (Entity*, const vector3df&), CameraComponent*), asCALL_CDECL); assert(r >= 0);

    r = engine->RegisterObjectMethod("CameraComponent", "CameraComponent& opAssign(const CameraComponent &in)",
                                     asFUNCTION(assignT<CameraComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0);

    // Bind CameraComponent class functions.
    r = engine->RegisterObjectMethod("CameraComponent", "void bindTargetAndRotation(bool)",
                                     asMETHOD(CameraComponent, bindTargetAndRotation), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "bool getTargetAndRotationBinding()",
                                     asMETHOD(CameraComponent, getTargetAndRotationBinding), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("CameraComponent", "f32 getAspectRatio()",
                                     asMETHOD(CameraComponent, getAspectRatio), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "f32 getFarValue()",
                                     asMETHOD(CameraComponent, getFarValue), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "f32 getFOV()",
                                     asMETHOD(CameraComponent, getFOV), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "f32 getNearValue()",
                                     asMETHOD(CameraComponent, getNearValue), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "const matrix4& getProjectionMatrix()",
                                     asMETHOD(CameraComponent, getProjectionMatrix), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "const vector3df& getTarget()",
                                     asMETHOD(CameraComponent, getTarget), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "const vector3df& getUpVector()",
                                     asMETHOD(CameraComponent, getUpVector), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "const matrix4& getViewMatrix()",
                                     asMETHOD(CameraComponent, getViewMatrix), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "bool getIsOrthogonal()",
                                     asMETHOD(CameraComponent, getIsOrthogonal), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("CameraComponent", "void setAsMainCamera()",
                                     asMETHOD(CameraComponent, setAsMainCamera), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setAspectRatio(f32)",
                                     asMETHOD(CameraComponent, setAspectRatio), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setFarValue(f32)",
                                     asMETHOD(CameraComponent, setFarValue), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setFOV(f32)",
                                     asMETHOD(CameraComponent, setFOV), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setNearValue(f32)",
                                     asMETHOD(CameraComponent, setNearValue), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setProjectionMatrix(const matrix4 &in, bool)",
                                     asMETHOD(CameraComponent, setProjectionMatrix), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setRotation(const vector3df &in)",
                                     asMETHOD(CameraComponent, setRotation), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setTarget(const vector3df &in)",
                                     asMETHOD(CameraComponent, setTarget), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setUpVector(const vector3df &in)",
                                     asMETHOD(CameraComponent, setUpVector), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("CameraComponent", "void setNormalMode()",
                                     asMETHOD(CameraComponent, setNormalMode), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setFPSMode(f32, f32, bool, f32)",
                                     asMETHOD(CameraComponent, setFPSMode), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("CameraComponent", "void setMayaMode(f32, f32, f32)",
                                     asMETHOD(CameraComponent, setMayaMode), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
